package think.thread.sychron.c02.toast;

import java.util.concurrent.TimeUnit;

public class Toaster implements Runnable{
	
	private ToastQueue dry;
	private int id=1;
	
	public Toaster(ToastQueue dQueue){
		dry=dQueue;
	}
	
	public void run() {
		try {
			while(!Thread.interrupted()){
				Toast t=new Toast(id++);
				System.out.println(t);
				dry.put(t);
				TimeUnit.MILLISECONDS.sleep(100);
			}
		} catch (Exception e) {
			System.out.println("exit via interrupted...");
		}
	}
	
}
